home *** CD-ROM | disk | FTP | other *** search
- #include <Pilot.h>
- #ifdef __GNUC__
- # include "Callbacks.h"
- #endif
-
- #include "resource.h"
-
- #include <SysEvtMgr.h>
- #include <System/SystemMgr.h>
-
- static Err StartApplication(void)
- {
- FrmGotoForm(BatBeltForm);
- return 0;
- }
-
- //static void StopApplication(void)
- //{
- //}
-
- static Boolean MyFormHandleEvent(EventPtr event)
- {
- Boolean handled;
- RectangleType scrollrect,fillrect;
- DirectionType dir;
- #ifdef __GNUC__
- CALLBACK_PROLOGUE
- #endif
- handled = false;
- switch (event->eType)
- {
- case frmOpenEvent:
- FrmDrawForm(FrmGetActiveForm());
- handled = true;
- break;
- }
- #ifdef __GNUC__
- CALLBACK_EPILOGUE
- #endif
- return(handled);
- }
-
- static Boolean ApplicationHandleEvent(EventPtr event)
- {
- FormPtr frm;
- Int formId;
- Boolean handled = false;
-
- if (event->eType == frmLoadEvent)
- {
- // Load the form resource specified in the event then activate the form.
- formId = event->data.frmLoad.formID;
- frm = FrmInitForm(formId);
- FrmSetActiveForm(frm);
-
- // Set the event handler for the form. The handler of the currently
- // active form is called by FrmDispatchEvent each time it receives an event.
- switch (formId)
- {
- case BatBeltForm:
- FrmSetEventHandler(frm, MyFormHandleEvent);
- break;
- }
- handled = true;
- }
-
- return handled;
- }
-
- static void EventLoop(void)
- {
- EventType event;
- Word error;
-
- do
- {
- EvtGetEvent(&event, evtWaitForever);
- if (! SysHandleEvent(&event))
- if (! MenuHandleEvent(0, &event, &error))
- if (! ApplicationHandleEvent(&event))
- FrmDispatchEvent(&event);
- }
- while (event.eType != appStopEvent);
- }
-
- DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags)
- {
- Err err = 0;
- UInt warnThres = 226;
- UInt critThres = 160;
- SysBatteryKind batType=sysBatteryKindNiCad;
- switch(cmd)
- {
- case sysAppLaunchCmdNormalLaunch:
- if ((err = StartApplication()) == 0)
- {
- EventLoop();
- // StopApplication();
- }
- break;
- case sysAppLaunchCmdSystemReset:
- SysBatteryInfoV20(1,&warnThres,&critThres,NULL,&batType,NULL);
- break;
- }
- return err;
- }
-